var app = getApp()
var httpTool = require('../../utils/network.js')
Page({
  data: {
    array: [],
    schoolId: '',   //学校ID
    schoolName: '',   //学校名称
    searchKeyWord:'',//查询关键字
  },
  onLoad: function (options) {
    // 生命周期函数--监听页面加载
    this.getListData()
  },
  onReady: function () {
    // 生命周期函数--监听页面初次渲染完成

  },
  onShow: function () {
    // 生命周期函数--监听页面显示

  },
  onHide: function () {
    // 生命周期函数--监听页面隐藏

  },
  onUnload: function () {
    // 生命周期函数--监听页面卸载

  },
  onPullDownRefresh: function () {
    // 页面相关事件处理函数--监听用户下拉动作

  },
  onReachBottom: function () {
    // 页面上拉触底事件的处理函数

  },
  //搜索监听
  searchListen: function (event) {
    this.data.searchKeyWord = event.detail.value;
    this.getListData();
  },
  selectModelClick: function (event) {

    var model = event.currentTarget.dataset.model
    console.log(model)
    app.schoolData.schoolId = model.id;
    app.schoolData.schoolName = model.schoolName;
    wx.navigateBack({
      delta: 1
    })

  },
  getListData: function () {
    var that = this
    var url = app.data.httpUrl + 'v1/index/getOpenSchoolList'
    var param = { schoolName: this.data.searchKeyWord}
    console.log(param)
    httpTool.sendRequest(url, param, '加载中...', function (res) {
      that.setData({
        array: res.list
      })
    }, function (error) {

    });
  }
})